window.myLocalStorage = {
  setItem(key, value) {
    localStorage.setItem(
      key,
      JSON.stringify({
        date: new Date().toLocaleString(),
        data: value,
      }),
    );
  },
  getItem(key, def = null) {
    try {
      let value = JSON.parse(localStorage.getItem(key));
      return value ? value.data : def;
    } catch (e) {
      return null;
    }
  },
};
